home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / OSA.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  50.7 KB  |  1,460 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        OSA.h
  3.  
  4.      Contains:    Open Scripting Architecture Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.4
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1992-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OSA__
  18. #define __OSA__
  19.  
  20. #ifndef __MACERRORS__
  21.     #include <MacErrors.h>
  22. #endif
  23.  
  24. #ifndef __APPLEEVENTS__
  25.     #include <AppleEvents.h>
  26. #endif
  27.  
  28. #ifndef __AEOBJECTS__
  29.     #include <AEObjects.h>
  30. #endif
  31.  
  32. #ifndef __COMPONENTS__
  33.     #include <Components.h>
  34. #endif
  35.  
  36. #ifndef __MACERRORS__
  37.     #include <MacErrors.h>
  38. #endif
  39.  
  40.  
  41.  
  42.  
  43. #if PRAGMA_ONCE
  44. #pragma once
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. #if PRAGMA_IMPORT
  52. #pragma import on
  53. #endif
  54.  
  55. #if PRAGMA_STRUCT_ALIGN
  56.     #pragma options align=mac68k
  57. #elif PRAGMA_STRUCT_PACKPUSH
  58.     #pragma pack(push, 2)
  59. #elif PRAGMA_STRUCT_PACK
  60.     #pragma pack(2)
  61. #endif
  62.  
  63. /**************************************************************************
  64.     Types and Constants
  65. **************************************************************************/
  66.  
  67. /*    The componenent manager type code for components that
  68.         support the OSA interface defined here. */
  69. /* 0x6f736120 */
  70. enum {
  71.     kOSAComponentType            = FOUR_CHAR_CODE('osa ')
  72. };
  73.  
  74. /* 0x73637074 */
  75. enum {
  76.     kOSAGenericScriptingComponentSubtype = FOUR_CHAR_CODE('scpt')
  77. };
  78.  
  79. /*    Type of script document files.    */
  80. /* 0x6f736173 */
  81. enum {
  82.     kOSAFileType                = FOUR_CHAR_CODE('osas')
  83. };
  84.  
  85. /*
  86.         Suite and event code of the RecordedText event. 
  87.         (See OSAStartRecording, below.)
  88.     */
  89. /* 0x61736372 */
  90. enum {
  91.     kOSASuite                    = FOUR_CHAR_CODE('ascr')
  92. };
  93.  
  94. /* 0x72656364 */
  95. enum {
  96.     kOSARecordedText            = FOUR_CHAR_CODE('recd')
  97. };
  98.  
  99. /* Selector returns boolean */
  100. /* 0x6d6f6469 */
  101. enum {
  102.     kOSAScriptIsModified        = FOUR_CHAR_CODE('modi')
  103. };
  104.  
  105. /* Selector returns boolean */
  106. /* 0x63736372 */
  107. enum {
  108.     kOSAScriptIsTypeCompiledScript = FOUR_CHAR_CODE('cscr')
  109. };
  110.  
  111. /* Selector returns boolean */
  112. /* 0x76616c75 */
  113. enum {
  114.     kOSAScriptIsTypeScriptValue    = FOUR_CHAR_CODE('valu')
  115. };
  116.  
  117. /* Selector returns boolean */
  118. /* 0x636e7478 */
  119. enum {
  120.     kOSAScriptIsTypeScriptContext = FOUR_CHAR_CODE('cntx')
  121. };
  122.  
  123. /* Selector returns a DescType which may be passed to OSACoerceToDesc */
  124. /* 0x62657374 */
  125. enum {
  126.     kOSAScriptBestType            = FOUR_CHAR_CODE('best')
  127. };
  128.  
  129. /*
  130.         This selector is used to determine whether a script has source 
  131.         associated with it that when given to OSAGetSource, the call will not
  132.         fail.  The selector returns a boolean.
  133.     */
  134. /* 0x67737263 */
  135. enum {
  136.     kOSACanGetSource            = FOUR_CHAR_CODE('gsrc')
  137. };
  138.  
  139.  
  140. enum {
  141.     typeOSADialectInfo            = FOUR_CHAR_CODE('difo'),        /*  0x6469666f   */
  142.     keyOSADialectName            = FOUR_CHAR_CODE('dnam'),        /*  0x646e616d   */
  143.     keyOSADialectCode            = FOUR_CHAR_CODE('dcod'),        /*  0x64636f64   */
  144.     keyOSADialectLangCode        = FOUR_CHAR_CODE('dlcd'),        /*  0x646c6364   */
  145.     keyOSADialectScriptCode        = FOUR_CHAR_CODE('dscd')        /*  0x64736364   */
  146. };
  147.  
  148. typedef ComponentResult                 OSAError;
  149. /* Under the Open Scripting Architecture all error results are longs */
  150. typedef unsigned long                     OSAID;
  151. /*
  152.         OSAIDs allow transparent manipulation of scripts associated with
  153.          various scripting systems.
  154.     */
  155. enum {
  156.     kOSANullScript                = 0L
  157. };
  158.  
  159. /* No -script constant. */
  160. enum {
  161.     kOSANullMode                = 0,                            /* sounds better */
  162.     kOSAModeNull                = 0                                /* tastes consistent */
  163. };
  164.  
  165. /*
  166.         Some routines take flags that control their execution.  This constant
  167.         declares default mode settings are used.
  168.     */
  169. typedef CALLBACK_API( OSErr , OSACreateAppleEventProcPtr )(AEEventClass theAEEventClass, AEEventID theAEEventID, const AEAddressDesc *target, short returnID, long transactionID, AppleEvent *result, long refCon);
  170. typedef CALLBACK_API( OSErr , OSASendProcPtr )(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc, long refCon);
  171. typedef STACK_UPP_TYPE(OSACreateAppleEventProcPtr)                 OSACreateAppleEventUPP;
  172. typedef STACK_UPP_TYPE(OSASendProcPtr)                             OSASendUPP;
  173. #if OPAQUE_UPP_TYPES
  174.     EXTERN_API(OSACreateAppleEventUPP)
  175.     NewOSACreateAppleEventUPP       (OSACreateAppleEventProcPtr userRoutine);
  176.  
  177.     EXTERN_API(OSASendUPP)
  178.     NewOSASendUPP                   (OSASendProcPtr            userRoutine);
  179.  
  180.     EXTERN_API(void)
  181.     DisposeOSACreateAppleEventUPP    (OSACreateAppleEventUPP userUPP);
  182.  
  183.     EXTERN_API(void)
  184.     DisposeOSASendUPP               (OSASendUPP                userUPP);
  185.  
  186.     EXTERN_API(OSErr)
  187.     InvokeOSACreateAppleEventUPP    (AEEventClass            theAEEventClass,
  188.                                     AEEventID                theAEEventID,
  189.                                     const AEAddressDesc *    target,
  190.                                     short                    returnID,
  191.                                     long                    transactionID,
  192.                                     AppleEvent *            result,
  193.                                     long                    refCon,
  194.                                     OSACreateAppleEventUPP    userUPP);
  195.  
  196.     EXTERN_API(OSErr)
  197.     InvokeOSASendUPP               (const AppleEvent *        theAppleEvent,
  198.                                     AppleEvent *            reply,
  199.                                     AESendMode                sendMode,
  200.                                     AESendPriority            sendPriority,
  201.                                     long                    timeOutInTicks,
  202.                                     AEIdleUPP                idleProc,
  203.                                     AEFilterUPP                filterProc,
  204.                                     long                    refCon,
  205.                                     OSASendUPP                userUPP);
  206.  
  207. #else
  208.     enum { uppOSACreateAppleEventProcInfo = 0x000FEFE0 };             /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 2_bytes, 4_bytes, 4_bytes, 4_bytes) */
  209.     enum { uppOSASendProcInfo = 0x003FEFE0 };                         /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 2_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  210.     #define NewOSACreateAppleEventUPP(userRoutine)                     (OSACreateAppleEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, GetCurrentArchitecture())
  211.     #define NewOSASendUPP(userRoutine)                                 (OSASendUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSASendProcInfo, GetCurrentArchitecture())
  212.     #define DisposeOSACreateAppleEventUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  213.     #define DisposeOSASendUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  214.     #define InvokeOSACreateAppleEventUPP(theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon, userUPP)  (OSErr)CALL_SEVEN_PARAMETER_UPP((userUPP), uppOSACreateAppleEventProcInfo, (theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  215.     #define InvokeOSASendUPP(theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon, userUPP)  (OSErr)CALL_EIGHT_PARAMETER_UPP((userUPP), uppOSASendProcInfo, (theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  216. #endif
  217. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  218. #define NewOSACreateAppleEventProc(userRoutine)                 NewOSACreateAppleEventUPP(userRoutine)
  219. #define NewOSASendProc(userRoutine)                             NewOSASendUPP(userRoutine)
  220. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon) InvokeOSACreateAppleEventUPP(theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon, userRoutine)
  221. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon) InvokeOSASendUPP(theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon, userRoutine)
  222. /**************************************************************************
  223.     OSA Interface Descriptions
  224. **************************************************************************
  225.     The OSA Interface is broken down into a required interface, and several
  226.     optional interfaces to support additional functionality.  A given scripting
  227.     component may choose to support only some of the optional interfaces in
  228.     addition to the basic interface.  The OSA Component Flags may be used to 
  229.     query the Component Manager to find a scripting component with a particular
  230.     capability, or determine if a particular scripting component supports a 
  231.     particular capability.
  232. **************************************************************************/
  233. /* OSA Component Flags: */
  234. enum {
  235.     kOSASupportsCompiling        = 0x0002,
  236.     kOSASupportsGetSource        = 0x0004,
  237.     kOSASupportsAECoercion        = 0x0008,
  238.     kOSASupportsAESending        = 0x0010,
  239.     kOSASupportsRecording        = 0x0020,
  240.     kOSASupportsConvenience        = 0x0040,
  241.     kOSASupportsDialects        = 0x0080,
  242.     kOSASupportsEventHandling    = 0x0100
  243. };
  244.  
  245. /* Component Selectors: */
  246. enum {
  247.     kOSASelectLoad                = 0x0001,
  248.     kOSASelectStore                = 0x0002,
  249.     kOSASelectExecute            = 0x0003,
  250.     kOSASelectDisplay            = 0x0004,
  251.     kOSASelectScriptError        = 0x0005,
  252.     kOSASelectDispose            = 0x0006,
  253.     kOSASelectSetScriptInfo        = 0x0007,
  254.     kOSASelectGetScriptInfo        = 0x0008,
  255.     kOSASelectSetActiveProc        = 0x0009,
  256.     kOSASelectGetActiveProc        = 0x000A
  257. };
  258.  
  259. /* Compiling: */
  260. enum {
  261.     kOSASelectScriptingComponentName = 0x0102,
  262.     kOSASelectCompile            = 0x0103,
  263.     kOSASelectCopyID            = 0x0104
  264. };
  265.  
  266. /* GetSource: */
  267. enum {
  268.     kOSASelectGetSource            = 0x0201
  269. };
  270.  
  271. /* AECoercion: */
  272. enum {
  273.     kOSASelectCoerceFromDesc    = 0x0301,
  274.     kOSASelectCoerceToDesc        = 0x0302
  275. };
  276.  
  277. /* AESending: */
  278. enum {
  279.     kOSASelectSetSendProc        = 0x0401,
  280.     kOSASelectGetSendProc        = 0x0402,
  281.     kOSASelectSetCreateProc        = 0x0403,
  282.     kOSASelectGetCreateProc        = 0x0404,
  283.     kOSASelectSetDefaultTarget    = 0x0405
  284. };
  285.  
  286. /* Recording: */
  287. enum {
  288.     kOSASelectStartRecording    = 0x0501,
  289.     kOSASelectStopRecording        = 0x0502
  290. };
  291.  
  292. /* Convenience: */
  293. enum {
  294.     kOSASelectLoadExecute        = 0x0601,
  295.     kOSASelectCompileExecute    = 0x0602,
  296.     kOSASelectDoScript            = 0x0603
  297. };
  298.  
  299. /* Dialects: */
  300. enum {
  301.     kOSASelectSetCurrentDialect    = 0x0701,
  302.     kOSASelectGetCurrentDialect    = 0x0702,
  303.     kOSASelectAvailableDialects    = 0x0703,
  304.     kOSASelectGetDialectInfo    = 0x0704,
  305.     kOSASelectAvailableDialectCodeList = 0x0705
  306. };
  307.  
  308. /* Event Handling: */
  309. enum {
  310.     kOSASelectSetResumeDispatchProc = 0x0801,
  311.     kOSASelectGetResumeDispatchProc = 0x0802,
  312.     kOSASelectExecuteEvent        = 0x0803,
  313.     kOSASelectDoEvent            = 0x0804,
  314.     kOSASelectMakeContext        = 0x0805
  315. };
  316.  
  317. /* scripting component specific selectors are added beginning with this value  */
  318. enum {
  319.     kOSASelectComponentSpecificStart = 0x1001
  320. };
  321.  
  322.  
  323. /*        Mode Flags:
  324.  
  325.     Warning: These should not conflict with the AESend mode flags in
  326.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  327. */
  328.  
  329. /*
  330.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  331.           instruct the scripting component to not retain the "source" of an
  332.           expression.  This will cause the OSAGetSource call to return the error
  333.           errOSASourceNotAvailable if used.  However, some scripting components
  334.           may not retain the source anyway.  This is mainly used when either space
  335.           efficiency is desired, or a script is to be "locked" so that its
  336.           implementation may not be viewed.
  337.     */
  338. enum {
  339.     kOSAModePreventGetSource    = 0x00000001
  340. };
  341.  
  342. /*
  343.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  344.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  345.           indicate whether or not the script may interact with the user, switch
  346.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  347.           corresponding AESend mode supplied.
  348.     */
  349. enum {
  350.     kOSAModeNeverInteract        = kAENeverInteract,
  351.     kOSAModeCanInteract            = kAECanInteract,
  352.     kOSAModeAlwaysInteract        = kAEAlwaysInteract,
  353.     kOSAModeDontReconnect        = kAEDontReconnect
  354. };
  355.  
  356. /*
  357.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  358.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  359.           indicate whether or not AppleEvents should be sent with the
  360.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  361.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  362.           provide a more convenient default, i.e. not supplying any mode
  363.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  364.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  365.           without kAECanSwitchLayer.
  366.     */
  367. enum {
  368.     kOSAModeCantSwitchLayer        = 0x00000040
  369. };
  370.  
  371. /*
  372.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  373.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  374.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  375.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  376.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  377.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  378.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  379.           cause AESend to be called without kAEDontRecord.
  380.     */
  381. enum {
  382.     kOSAModeDoRecord            = 0x00001000
  383. };
  384.  
  385. /*
  386.         This is a mode flag for OSACompile that indicates that a context should
  387.           be created as the result of compilation. All handler definitions are
  388.           inserted into the new context, and variables are initialized by
  389.           evaluating their initial values in a null context (i.e. they must be
  390.           constant expressions).
  391.     */
  392. enum {
  393.     kOSAModeCompileIntoContext    = 0x00000002
  394. };
  395.  
  396. /*
  397.         This is a mode flag for OSACompile that indicates that the previous
  398.           script ID (input to OSACompile) should be augmented with any new
  399.           definitions in the sourceData rather than replaced with a new script.
  400.           This means that the previous script ID must designate a context.
  401.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  402.           to be implicitly used, causing any new definitions to be initialized
  403.           in a null context.
  404.     */
  405. enum {
  406.     kOSAModeAugmentContext        = 0x00000004
  407. };
  408.  
  409. /*
  410.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  411.           that output only need be human-readable, not re-compilable by OSACompile.
  412.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  413.           off of string values, long lists may have elipses, etc.
  414.     */
  415. enum {
  416.     kOSAModeDisplayForHumans    = 0x00000008
  417. };
  418.  
  419. /*
  420.         This mode flag may be passed to OSAStore in the case where the scriptID
  421.           is a context.  This causes the context to be saved, but not the context's
  422.           parent context.  When the stored context is loaded back in, the parent
  423.           will be kOSANullScript.
  424.     */
  425. enum {
  426.     kOSAModeDontStoreParent        = 0x00010000
  427. };
  428.  
  429. /*
  430.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  431.           be dispatched to the direct object of the event. The direct object (or
  432.           subject attribute if the direct object is a non-object specifier) will
  433.           be resolved, and the resulting script object will be the recipient of
  434.           the message. The context argument to OSAExecuteEvent will serve as the
  435.           root of the lookup/resolution process.
  436.     */
  437. enum {
  438.     kOSAModeDispatchToDirectObject = 0x00020000
  439. };
  440.  
  441. /*
  442.         This mode flag may be passed to OSAExecuteEvent to indicate that
  443.           components do not have to get the data of object specifier arguments.
  444.     */
  445. enum {
  446.     kOSAModeDontGetDataForArguments = 0x00040000
  447. };
  448.  
  449. /**************************************************************************
  450.     OSA Basic Scripting Interface
  451. **************************************************************************
  452.     Scripting components must at least support the Basic Scripting interface.
  453. **************************************************************************/
  454. /*        Loading and Storing Scripts:
  455.  
  456.     These routines allow scripts to be loaded and stored in their internal
  457.     (possibly compiled, non-text) representation.
  458. */
  459.  
  460. /* Resource type for scripts */
  461. enum {
  462.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype
  463. };
  464.  
  465. /*
  466.         Default type given to OSAStore which creates "generic" loadable script
  467.           data descriptors.
  468.     */
  469. enum {
  470.     typeOSAGenericStorage        = kOSAScriptResourceType
  471. };
  472.  
  473. EXTERN_API( OSAError )
  474. OSALoad                            (ComponentInstance         scriptingComponent,
  475.                                  const AEDesc *            scriptData,
  476.                                  long                     modeFlags,
  477.                                  OSAID *                resultingScriptID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0001, 0x7000, 0xA82A);
  478.  
  479. /*
  480.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  481.     
  482.         Errors:
  483.             badComponentInstance        invalid scripting component instance
  484.             errOSASystemError
  485.             errOSABadStorageType:        scriptData not for this scripting component
  486.             errOSACorruptData:            data seems to be corrupt
  487.             errOSADataFormatObsolete    script data format is no longer supported
  488.             errOSADataFormatTooNew        script data format is from a newer version
  489.         
  490.         ModeFlags:
  491.             kOSAModePreventGetSource
  492.     */
  493. EXTERN_API( OSAError )
  494. OSAStore                        (ComponentInstance         scriptingComponent,
  495.                                  OSAID                     scriptID,
  496.                                  DescType                 desiredType,
  497.                                  long                     modeFlags,
  498.                                  AEDesc *                resultingScriptData)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0002, 0x7000, 0xA82A);
  499.  
  500. /*
  501.         OSAComponentFunctionInline(kOSASelectStore, 16);
  502.     
  503.         Errors:
  504.             badComponentInstance    invalid scripting component instance
  505.             errOSASystemError
  506.             errOSAInvalidID
  507.             errOSABadStorageType:    desiredType not for this scripting component
  508.         
  509.         ModeFlags:
  510.             kOSAModePreventGetSource
  511.             kOSAModeDontStoreParent
  512.     */
  513. /* Executing Scripts: */
  514. EXTERN_API( OSAError )
  515. OSAExecute                        (ComponentInstance         scriptingComponent,
  516.                                  OSAID                     compiledScriptID,
  517.                                  OSAID                     contextID,
  518.                                  long                     modeFlags,
  519.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0003, 0x7000, 0xA82A);
  520.  
  521. /*
  522.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  523.         This call runs a script.  The contextID represents the environment
  524.         with which global variables in the script are resolved.  The constant
  525.         kOSANullScript may be used for the contextID if the application wishes
  526.         to not deal with context directly (a default one is associated with each
  527.         scripting component instance).  The resultingScriptValueID is the 
  528.         result of evaluation, and contains a value which may be displayed using
  529.         the OSAGetSource call.  The modeFlags convey scripting component
  530.         specific information.
  531.     
  532.         Errors:
  533.             badComponentInstance    invalid scripting component instance
  534.             errOSASystemError
  535.             errOSAInvalidID
  536.             errOSAScriptError:        the executing script got an error
  537.     
  538.         ModeFlags:
  539.             kOSAModeNeverInteract
  540.             kOSAModeCanInteract
  541.             kOSAModeAlwaysInteract
  542.             kOSAModeCantSwitchLayer
  543.             kOSAModeDontReconnect
  544.             kOSAModeDoRecord
  545.     */
  546. /* Displaying results: */
  547. EXTERN_API( OSAError )
  548. OSADisplay                        (ComponentInstance         scriptingComponent,
  549.                                  OSAID                     scriptValueID,
  550.                                  DescType                 desiredType,
  551.                                  long                     modeFlags,
  552.                                  AEDesc *                resultingText)                        FIVEWORDINLINE(0x2F3C, 0x0010, 0x0004, 0x7000, 0xA82A);
  553.  
  554. /*
  555.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  556.         This call is used to convert results (script value IDs) into displayable
  557.         text. The desiredType should be at least typeChar, and modeFlags are
  558.         scripting system specific flags to control the formatting of the
  559.         resulting text. This call differs from OSAGetSource in that (1) it
  560.         always produces at least typeChar, (2) is only works on script values,
  561.         (3) it may display it's output in non-compilable form (e.g. without
  562.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  563.         (4) it is required by the basic scripting interface.
  564.     
  565.         Errors:
  566.             badComponentInstance    invalid scripting component instance
  567.             errOSASystemError
  568.             errOSAInvalidID
  569.             errAECoercionFail:        desiredType not supported by scripting component
  570.     
  571.         ModeFlags:
  572.             kOSAModeDisplayForHumans
  573.     */
  574. /* Getting Error Information: */
  575. EXTERN_API( OSAError )
  576. OSAScriptError                    (ComponentInstance         scriptingComponent,
  577.                                  OSType                 selector,
  578.                                  DescType                 desiredType,
  579.                                  AEDesc *                resultingErrorDescription)            FIVEWORDINLINE(0x2F3C, 0x000C, 0x0005, 0x7000, 0xA82A);
  580.  
  581. /*
  582.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  583.         Whenever script execution returns errOSAExecutionError, this routine
  584.         may be used to get information about that error.  The selector describes
  585.         the type of information desired about the error (various selectors are
  586.         listed below).  The desiredType indicates the data type of the result
  587.         desired for that selector.
  588.     
  589.         Errors:
  590.             badComponentInstance    invalid scripting component instance
  591.             errOSASystemError
  592.             errOSABadSelector:        selector not supported by scripting component
  593.             errAECoercionFail:        desiredType not supported by scripting component
  594.     */
  595. /* OSAScriptError selectors: */
  596. /*
  597.         This selector is used to determine the error number of a script error.
  598.         These error numbers may be either system error numbers, or error numbers
  599.         that are scripting component specific.
  600.         Required desiredTypes:    
  601.               typeShortInteger
  602.     */
  603. enum {
  604.     kOSAErrorNumber                = keyErrorNumber
  605. };
  606.  
  607. /*
  608.         This selector is used to determine the full error message associated
  609.         with the error number.  It should include the name of the application
  610.         which caused the error, as well as the specific error that occurred.
  611.         This selector is sufficient for simple error reporting (but see
  612.         kOSAErrorBriefMessage, below).
  613.         Required desiredTypes:
  614.             typeChar                    error message string
  615.     */
  616. enum {
  617.     kOSAErrorMessage            = keyErrorString
  618. };
  619.  
  620. /*
  621.         This selector is used to determine a brief error message associated with
  622.         the error number.  This message and should not mention the name of the
  623.         application which caused the error, any partial results or offending
  624.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  625.         kOSAErrorOffendingObject, below).
  626.         Required desiredTypes:
  627.               typeChar                    brief error message string
  628.     */
  629. /*  0x65727262  */
  630. enum {
  631.     kOSAErrorBriefMessage        = FOUR_CHAR_CODE('errb')
  632. };
  633.  
  634. /*
  635.         This selector is used to determine which application actually got the
  636.         error (if it was the result of an AESend), or the current application
  637.         if ....
  638.         Required desiredTypes:
  639.               typeProcessSerialNumber        PSN of the errant application
  640.               typeChar                    name of the errant application
  641.     */
  642. /*  0x65726170  */
  643. enum {
  644.     kOSAErrorApp                = FOUR_CHAR_CODE('erap')
  645. };
  646.  
  647. /*
  648.         This selector is used to determine any partial result returned by an 
  649.         operation. If an AESend call failed, but a partial result was returned,
  650.         then the partial result may be returned as an AEDesc.
  651.         Required desiredTypes:
  652.               typeBest                    AEDesc of any partial result
  653.     */
  654. /*  0x70746c72   */
  655. enum {
  656.     kOSAErrorPartialResult        = FOUR_CHAR_CODE('ptlr')
  657. };
  658.  
  659. /*
  660.         This selector is used to determine any object which caused the error
  661.         that may have been indicated by an application.  The result is an 
  662.         AEDesc.
  663.         Required desiredTypes:
  664.               typeBest                    AEDesc of any offending object
  665.     */
  666. /*  0x65726f62   */
  667. enum {
  668.     kOSAErrorOffendingObject    = FOUR_CHAR_CODE('erob')
  669. };
  670.  
  671. /*
  672.         This selector is used to determine the type expected by a coercion 
  673.         operation if a type error occurred.
  674.     */
  675. /*  0x65727274   */
  676. enum {
  677.     kOSAErrorExpectedType        = FOUR_CHAR_CODE('errt')
  678. };
  679.  
  680. /*
  681.         This selector is used to determine the source text range (start and 
  682.         end positions) of where the error occurred.
  683.         Required desiredTypes:
  684.               typeOSAErrorRange
  685.     */
  686. /*  0x65726e67  */
  687. enum {
  688.     kOSAErrorRange                = FOUR_CHAR_CODE('erng')
  689. };
  690.  
  691. /*
  692.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  693.         of type short.
  694.     */
  695. /*  0x65726e67   */
  696. enum {
  697.     typeOSAErrorRange            = FOUR_CHAR_CODE('erng')
  698. };
  699.  
  700. /* Field of a typeOSAErrorRange record of typeShortInteger */
  701. /*  0x73726373    */
  702. enum {
  703.     keyOSASourceStart            = FOUR_CHAR_CODE('srcs')
  704. };
  705.  
  706. /* Field of a typeOSAErrorRange record of typeShortInteger */
  707. /*  0x73726365   */
  708. enum {
  709.     keyOSASourceEnd                = FOUR_CHAR_CODE('srce')
  710. };
  711.  
  712. /* Disposing Script IDs: */
  713. EXTERN_API( OSAError )
  714. OSADispose                        (ComponentInstance         scriptingComponent,
  715.                                  OSAID                     scriptID)                            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0006, 0x7000, 0xA82A);
  716.  
  717. /*
  718.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  719.         Disposes a script or context.
  720.     
  721.         Errors:
  722.             badComponentInstance    invalid scripting component instance
  723.             errOSASystemError
  724.             errOSAInvalidID
  725.     */
  726. /* Getting and Setting Script Information: */
  727. EXTERN_API( OSAError )
  728. OSASetScriptInfo                (ComponentInstance         scriptingComponent,
  729.                                  OSAID                     scriptID,
  730.                                  OSType                 selector,
  731.                                  long                     value)                                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0007, 0x7000, 0xA82A);
  732.  
  733. /*
  734.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  735.     
  736.         Errors:
  737.             badComponentInstance    invalid scripting component instance
  738.             errOSASystemError
  739.             errOSAInvalidID
  740.             errOSABadSelector:        selector not supported by scripting component
  741.                                     or selector not for this scriptID
  742.     */
  743. EXTERN_API( OSAError )
  744. OSAGetScriptInfo                (ComponentInstance         scriptingComponent,
  745.                                  OSAID                     scriptID,
  746.                                  OSType                 selector,
  747.                                  long *                    result)                                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0008, 0x7000, 0xA82A);
  748.  
  749. /*
  750.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  751.     
  752.         Errors:
  753.             badComponentInstance    invalid scripting component instance
  754.             errOSASystemError
  755.             errOSAInvalidID
  756.             errOSABadSelector:        selector not supported by scripting component
  757.                                     or selector not for this scriptID
  758.     */
  759. /* Manipulating the ActiveProc:
  760.  
  761.     Scripting systems will supply default values for these procedures if they
  762.     are not set by the client:
  763. */
  764. typedef CALLBACK_API( OSErr , OSAActiveProcPtr )(long refCon);
  765. typedef STACK_UPP_TYPE(OSAActiveProcPtr)                         OSAActiveUPP;
  766. #if OPAQUE_UPP_TYPES
  767.     EXTERN_API(OSAActiveUPP)
  768.     NewOSAActiveUPP                   (OSAActiveProcPtr        userRoutine);
  769.  
  770.     EXTERN_API(void)
  771.     DisposeOSAActiveUPP               (OSAActiveUPP            userUPP);
  772.  
  773.     EXTERN_API(OSErr)
  774.     InvokeOSAActiveUPP               (long                    refCon,
  775.                                     OSAActiveUPP            userUPP);
  776.  
  777. #else
  778.     enum { uppOSAActiveProcInfo = 0x000000E0 };                     /* pascal 2_bytes Func(4_bytes) */
  779.     #define NewOSAActiveUPP(userRoutine)                             (OSAActiveUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSAActiveProcInfo, GetCurrentArchitecture())
  780.     #define DisposeOSAActiveUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  781.     #define InvokeOSAActiveUPP(refCon, userUPP)                     (OSErr)CALL_ONE_PARAMETER_UPP((userUPP), uppOSAActiveProcInfo, (refCon))
  782. #endif
  783. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  784. #define NewOSAActiveProc(userRoutine)                             NewOSAActiveUPP(userRoutine)
  785. #define CallOSAActiveProc(userRoutine, refCon)                    InvokeOSAActiveUPP(refCon, userRoutine)
  786. EXTERN_API( OSAError )
  787. OSASetActiveProc                (ComponentInstance         scriptingComponent,
  788.                                  OSAActiveUPP             activeProc,
  789.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0009, 0x7000, 0xA82A);
  790.  
  791. /*
  792.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  793.         If activeProc is nil, the default activeProc is used.
  794.     
  795.         Errors:
  796.             badComponentInstance    invalid scripting component instance
  797.             errOSASystemError
  798.     */
  799. EXTERN_API( OSAError )
  800. OSAGetActiveProc                (ComponentInstance         scriptingComponent,
  801.                                  OSAActiveUPP *            activeProc,
  802.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x000A, 0x7000, 0xA82A);
  803.  
  804. /*
  805.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  806.     
  807.         Errors:
  808.             badComponentInstance    invalid scripting component instance
  809.             errOSASystemError
  810.     */
  811. /**************************************************************************
  812.     OSA Optional Compiling Interface
  813. **************************************************************************
  814.     Scripting components that support the Compiling interface have the 
  815.     kOSASupportsCompiling bit set in it's ComponentDescription.
  816. **************************************************************************/
  817. EXTERN_API( OSAError )
  818. OSAScriptingComponentName        (ComponentInstance         scriptingComponent,
  819.                                  AEDesc *                resultingScriptingComponentName)    FIVEWORDINLINE(0x2F3C, 0x0004, 0x0102, 0x7000, 0xA82A);
  820.  
  821. /*
  822.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  823.         Given a scripting component, this routine returns the name of that
  824.         scripting component in a type that is coercable to text (typeChar).
  825.         The generic scripting component returns the name of the default
  826.         scripting component.  This name should be sufficient to convey to the
  827.         user the kind of script (syntax) he is expected to write.
  828.     
  829.         Errors:
  830.             badComponentInstance    invalid scripting component instance
  831.             errOSASystemError
  832.     */
  833. EXTERN_API( OSAError )
  834. OSACompile                        (ComponentInstance         scriptingComponent,
  835.                                  const AEDesc *            sourceData,
  836.                                  long                     modeFlags,
  837.                                  OSAID *                previousAndResultingScriptID)        FIVEWORDINLINE(0x2F3C, 0x000C, 0x0103, 0x7000, 0xA82A);
  838.  
  839. /*
  840.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  841.         Coerces input desc (possibly text) into a script's internal format.
  842.         Once compiled, the script is ready to run.  The modeFlags convey
  843.         scripting component specific information.  The previous script ID
  844.         (result parameter) is made to refer to the newly compiled script,
  845.         unless it was originally kOSANullScript.  In this case a new script
  846.         ID is created and used.
  847.     
  848.         Errors:
  849.             badComponentInstance    invalid scripting component instance
  850.             errOSASystemError
  851.             errAECoercionFail:        sourceData is not compilable
  852.             errOSAScriptError:        sourceData was a bad script (syntax error)
  853.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  854.                                     valid on input
  855.     
  856.         ModeFlags:
  857.             kOSAModePreventGetSource
  858.             kOSAModeCompileIntoContext
  859.             kOSAModeAugmentContext
  860.             kOSAModeNeverInteract
  861.             kOSAModeCanInteract
  862.             kOSAModeAlwaysInteract
  863.             kOSAModeCantSwitchLayer
  864.             kOSAModeDontReconnect
  865.             kOSAModeDoRecord
  866.     */
  867. EXTERN_API( OSAError )
  868. OSACopyID                        (ComponentInstance         scriptingComponent,
  869.                                  OSAID                     fromID,
  870.                                  OSAID *                toID)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0104, 0x7000, 0xA82A);
  871.  
  872. /*
  873.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  874.         If toID is a reference to kOSANullScript then it is updated to have a
  875.         new scriptID value.  This call can be used to perform undo or revert
  876.         operations on scripts. 
  877.     
  878.         Errors:
  879.             badComponentInstance    invalid scripting component instance
  880.             errOSASystemError
  881.             errOSAInvalidID
  882.     */
  883. /**************************************************************************
  884.     OSA Optional GetSource Interface
  885. **************************************************************************
  886.     Scripting components that support the GetSource interface have the 
  887.     kOSASupportsGetSource bit set in it's ComponentDescription.
  888. **************************************************************************/
  889. EXTERN_API( OSAError )
  890. OSAGetSource                    (ComponentInstance         scriptingComponent,
  891.                                  OSAID                     scriptID,
  892.                                  DescType                 desiredType,
  893.                                  AEDesc *                resultingSourceData)                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0201, 0x7000, 0xA82A);
  894.  
  895. /*
  896.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  897.         This routine causes a compiled script to be output in a form (possibly
  898.         text) such that it is suitable to be passed back to OSACompile.
  899.  
  900.         Errors:
  901.             badComponentInstance    invalid scripting component instance
  902.             errOSASystemError
  903.             errOSAInvalidID
  904.             errOSASourceNotAvailable    can't get source for this scriptID
  905.     */
  906. /**************************************************************************
  907.     OSA Optional AECoercion Interface
  908. **************************************************************************
  909.     Scripting components that support the AECoercion interface have the 
  910.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  911. **************************************************************************/
  912. EXTERN_API( OSAError )
  913. OSACoerceFromDesc                (ComponentInstance         scriptingComponent,
  914.                                  const AEDesc *            scriptData,
  915.                                  long                     modeFlags,
  916.                                  OSAID *                resultingScriptID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0301, 0x7000, 0xA82A);
  917.  
  918. /*
  919.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  920.         This routine causes script data to be coerced into a script value.
  921.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  922.         compiled script ID (mode flags for OSACompile may be used in this case).
  923.         Other scriptData descriptors create script value IDs.
  924.     
  925.         Errors:
  926.             badComponentInstance    invalid scripting component instance
  927.             errOSASystemError
  928.     
  929.         ModeFlags:
  930.             kOSAModePreventGetSource
  931.             kOSAModeCompileIntoContext
  932.             kOSAModeNeverInteract
  933.             kOSAModeCanInteract
  934.             kOSAModeAlwaysInteract
  935.             kOSAModeCantSwitchLayer
  936.             kOSAModeDontReconnect
  937.             kOSAModeDoRecord
  938.     */
  939. EXTERN_API( OSAError )
  940. OSACoerceToDesc                    (ComponentInstance         scriptingComponent,
  941.                                  OSAID                     scriptID,
  942.                                  DescType                 desiredType,
  943.                                  long                     modeFlags,
  944.                                  AEDesc *                result)                                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0302, 0x7000, 0xA82A);
  945.  
  946. /*
  947.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  948.         This routine causes a script value to be coerced into any desired form.
  949.         If the scriptID denotes a compiled script, then it may be coerced to 
  950.         typeAppleEvent.
  951.     
  952.         Errors:
  953.             badComponentInstance    invalid scripting component instance
  954.             errOSASystemError
  955.             errOSAInvalidID
  956.     */
  957. /**************************************************************************
  958.     OSA Optional AESending Interface
  959. **************************************************************************
  960.     Scripting components that support the AESending interface have the 
  961.     kOSASupportsAESending bit set in their ComponentDescription.
  962. **************************************************************************/
  963. /*
  964.     Scripting systems will supply default values for these procedures if they
  965.     are not set by the client:
  966. */
  967. EXTERN_API( OSAError )
  968. OSASetSendProc                    (ComponentInstance         scriptingComponent,
  969.                                  OSASendUPP             sendProc,
  970.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0401, 0x7000, 0xA82A);
  971.  
  972. /*
  973.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  974.         If sendProc is nil, the default sendProc is used.
  975.     
  976.         Errors:
  977.             badComponentInstance    invalid scripting component instance
  978.             errOSASystemError
  979.     */
  980. EXTERN_API( OSAError )
  981. OSAGetSendProc                    (ComponentInstance         scriptingComponent,
  982.                                  OSASendUPP *            sendProc,
  983.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0402, 0x7000, 0xA82A);
  984.  
  985. /*
  986.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  987.     
  988.         Errors:
  989.             badComponentInstance    invalid scripting component instance
  990.             errOSASystemError
  991.     */
  992. EXTERN_API( OSAError )
  993. OSASetCreateProc                (ComponentInstance         scriptingComponent,
  994.                                  OSACreateAppleEventUPP  createProc,
  995.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0403, 0x7000, 0xA82A);
  996.  
  997. /*
  998.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  999.         If createProc is nil, the default createProc is used.
  1000.     
  1001.         Errors:
  1002.             badComponentInstance    invalid scripting component instance
  1003.             errOSASystemError
  1004.     */
  1005. EXTERN_API( OSAError )
  1006. OSAGetCreateProc                (ComponentInstance         scriptingComponent,
  1007.                                  OSACreateAppleEventUPP * createProc,
  1008.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0404, 0x7000, 0xA82A);
  1009.  
  1010. /*
  1011.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1012.     
  1013.         Errors:
  1014.             badComponentInstance    invalid scripting component instance
  1015.             errOSASystemError
  1016.     */
  1017. EXTERN_API( OSAError )
  1018. OSASetDefaultTarget                (ComponentInstance         scriptingComponent,
  1019.                                  const AEAddressDesc *    target)                                FIVEWORDINLINE(0x2F3C, 0x0004, 0x0405, 0x7000, 0xA82A);
  1020.  
  1021. /*
  1022.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1023.         This routine sets the default target application for AE sending.
  1024.         It also establishes the default target from which terminologies come.
  1025.         It is effectively like having an AppleScript "tell" statement around
  1026.         the entire program.  If this routine is not called, or if the target 
  1027.         is a null AEDesc, then the current application is the default target.
  1028.     
  1029.         Errors:
  1030.             badComponentInstance    invalid scripting component instance
  1031.             errOSASystemError
  1032.     */
  1033. /**************************************************************************
  1034.     OSA Optional Recording Interface
  1035. **************************************************************************
  1036.     Scripting components that support the Recording interface have the 
  1037.     kOSASupportsRecording bit set in their ComponentDescription.
  1038. **************************************************************************/
  1039. EXTERN_API( OSAError )
  1040. OSAStartRecording                (ComponentInstance         scriptingComponent,
  1041.                                  OSAID *                compiledScriptToModifyID)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0501, 0x7000, 0xA82A);
  1042.  
  1043. /*
  1044.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1045.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1046.         new script ID is created and returned.  If the current application has
  1047.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1048.         are sent to the application containing the text of each AppleEvent 
  1049.         recorded.
  1050.     
  1051.         Errors:
  1052.             badComponentInstance    invalid scripting component instance
  1053.             errOSASystemError
  1054.             errOSAInvalidID
  1055.             errOSARecordingIsAlreadyOn
  1056.     */
  1057. EXTERN_API( OSAError )
  1058. OSAStopRecording                (ComponentInstance         scriptingComponent,
  1059.                                  OSAID                     compiledScriptID)                    FIVEWORDINLINE(0x2F3C, 0x0004, 0x0502, 0x7000, 0xA82A);
  1060.  
  1061. /*
  1062.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1063.         If compiledScriptID is not being recorded into or recording is not
  1064.         currently on, no error is returned.
  1065.     
  1066.         Errors:
  1067.             badComponentInstance    invalid scripting component instance
  1068.             errOSASystemError
  1069.             errOSAInvalidID
  1070.     */
  1071. /**************************************************************************
  1072.     OSA Optional Convenience Interface
  1073. **************************************************************************
  1074.     Scripting components that support the Convenience interface have the 
  1075.     kOSASupportsConvenience bit set in their ComponentDescription.
  1076. **************************************************************************/
  1077. EXTERN_API( OSAError )
  1078. OSALoadExecute                    (ComponentInstance         scriptingComponent,
  1079.                                  const AEDesc *            scriptData,
  1080.                                  OSAID                     contextID,
  1081.                                  long                     modeFlags,
  1082.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0601, 0x7000, 0xA82A);
  1083.  
  1084. /*
  1085.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1086.         This routine is effectively equivalent to calling OSALoad followed by
  1087.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1088.         resulting value ID is retained.
  1089.     
  1090.         Errors:
  1091.             badComponentInstance        invalid scripting component instance
  1092.             errOSASystemError
  1093.             errOSABadStorageType:        scriptData not for this scripting component
  1094.             errOSACorruptData:            data seems to be corrupt
  1095.             errOSADataFormatObsolete    script data format is no longer supported
  1096.             errOSADataFormatTooNew        script data format is from a newer version
  1097.             errOSAInvalidID
  1098.             errOSAScriptError:            the executing script got an error
  1099.     
  1100.         ModeFlags:
  1101.             kOSAModeNeverInteract
  1102.             kOSAModeCanInteract
  1103.             kOSAModeAlwaysInteract
  1104.             kOSAModeCantSwitchLayer
  1105.             kOSAModeDontReconnect
  1106.             kOSAModeDoRecord
  1107.     */
  1108. EXTERN_API( OSAError )
  1109. OSACompileExecute                (ComponentInstance         scriptingComponent,
  1110.                                  const AEDesc *            sourceData,
  1111.                                  OSAID                     contextID,
  1112.                                  long                     modeFlags,
  1113.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0602, 0x7000, 0xA82A);
  1114.  
  1115. /*
  1116.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1117.         This routine is effectively equivalent to calling OSACompile followed by
  1118.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1119.         resulting value ID is retained.
  1120.     
  1121.         Errors:
  1122.             badComponentInstance    invalid scripting component instance
  1123.             errOSASystemError
  1124.             errAECoercionFail:        sourceData is not compilable
  1125.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1126.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1127.                                     valid on input
  1128.             errOSAScriptError:        the executing script got an error
  1129.     
  1130.         ModeFlags:
  1131.             kOSAModeNeverInteract
  1132.             kOSAModeCanInteract
  1133.             kOSAModeAlwaysInteract
  1134.             kOSAModeCantSwitchLayer
  1135.             kOSAModeDontReconnect
  1136.             kOSAModeDoRecord
  1137.     */
  1138. EXTERN_API( OSAError )
  1139. OSADoScript                        (ComponentInstance         scriptingComponent,
  1140.                                  const AEDesc *            sourceData,
  1141.                                  OSAID                     contextID,
  1142.                                  DescType                 desiredType,
  1143.                                  long                     modeFlags,
  1144.                                  AEDesc *                resultingText)                        FIVEWORDINLINE(0x2F3C, 0x0014, 0x0603, 0x7000, 0xA82A);
  1145.  
  1146. /*
  1147.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1148.         This routine is effectively equivalent to calling OSACompile followed by
  1149.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1150.         and the resulting value are is disposed.  Only the resultingText
  1151.         descriptor is retained.  If a script error occur during processing, the 
  1152.         resultingText gets the error message of the error, and errOSAScriptError
  1153.         is returned.  OSAScriptError may still be used to extract more 
  1154.         information about the particular error.
  1155.     
  1156.         Errors:
  1157.             badComponentInstance    invalid scripting component instance
  1158.             errOSASystemError
  1159.             errAECoercionFail:        sourceData is not compilable or 
  1160.                                     desiredType not supported by scripting component
  1161.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1162.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1163.                                     valid on input
  1164.             errOSAScriptError:        the executing script got an error
  1165.     
  1166.         ModeFlags:
  1167.             kOSAModeNeverInteract
  1168.             kOSAModeCanInteract
  1169.             kOSAModeAlwaysInteract
  1170.             kOSAModeCantSwitchLayer
  1171.             kOSAModeDontReconnect
  1172.             kOSAModeDoRecord
  1173.             kOSAModeDisplayForHumans
  1174.     */
  1175. /**************************************************************************
  1176.     OSA Optional Dialects Interface
  1177. **************************************************************************
  1178.     Scripting components that support the Dialects interface have the 
  1179.     kOSASupportsDialects bit set in their ComponentDescription.
  1180. **************************************************************************/
  1181. /*
  1182.     These calls allows an scripting component that supports different dialects
  1183.     to dynamically switch between those dialects.  Although this interface is
  1184.     specified, the particular dialect codes are scripting component dependent.
  1185. */
  1186. EXTERN_API( OSAError )
  1187. OSASetCurrentDialect            (ComponentInstance         scriptingComponent,
  1188.                                  short                     dialectCode)                        FIVEWORDINLINE(0x2F3C, 0x0002, 0x0701, 0x7000, 0xA82A);
  1189.  
  1190. /*
  1191.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1192.     
  1193.         Errors:
  1194.             badComponentInstance    invalid scripting component instance
  1195.             errOSASystemError
  1196.             errOSANoSuchDialect:    invalid dialectCode
  1197.     */
  1198. EXTERN_API( OSAError )
  1199. OSAGetCurrentDialect            (ComponentInstance         scriptingComponent,
  1200.                                  short *                resultingDialectCode)                FIVEWORDINLINE(0x2F3C, 0x0004, 0x0702, 0x7000, 0xA82A);
  1201.  
  1202. /*
  1203.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1204.     
  1205.         Errors:
  1206.             badComponentInstance    invalid scripting component instance
  1207.             errOSASystemError
  1208.     */
  1209. EXTERN_API( OSAError )
  1210. OSAAvailableDialects            (ComponentInstance         scriptingComponent,
  1211.                                  AEDesc *                resultingDialectInfoList)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0703, 0x7000, 0xA82A);
  1212.  
  1213. /*
  1214.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1215.         This call return an AEList containing information about each of the
  1216.         currently available dialects of a scripting component.  Each item
  1217.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1218.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1219.         keyOSADialectScriptCode.
  1220.     
  1221.         Errors:
  1222.             badComponentInstance    invalid scripting component instance
  1223.             errOSASystemError
  1224.     */
  1225. EXTERN_API( OSAError )
  1226. OSAGetDialectInfo                (ComponentInstance         scriptingComponent,
  1227.                                  short                     dialectCode,
  1228.                                  OSType                 selector,
  1229.                                  AEDesc *                resultingDialectInfo)                FIVEWORDINLINE(0x2F3C, 0x000A, 0x0704, 0x7000, 0xA82A);
  1230.  
  1231. /*
  1232.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1233.         This call gives information about the specified dialect of a scripting
  1234.         component. It returns an AEDesc whose type depends on the selector 
  1235.         specified. Available selectors are the same as the field keys for a
  1236.         dialect info record. The type of AEDesc returned is the same as the 
  1237.         type of the field that has same key as the selector.
  1238.     
  1239.         Errors:
  1240.             badComponentInstance    invalid scripting component instance
  1241.             errOSASystemError
  1242.              errOSABadSelector
  1243.             errOSANoSuchDialect:    invalid dialectCode
  1244.     */
  1245. EXTERN_API( OSAError )
  1246. OSAAvailableDialectCodeList        (ComponentInstance         scriptingComponent,
  1247.                                  AEDesc *                resultingDialectCodeList)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0705, 0x7000, 0xA82A);
  1248.  
  1249. /*
  1250.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1251.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1252.         and  OSAGetDialectInfo to get information on dialects.
  1253.         This call return an AEList containing dialect code for each of the
  1254.         currently available dialects of a scripting component. Each dialect
  1255.         code is a short integer of type typeShortInteger.
  1256.     
  1257.         Errors:
  1258.             badComponentInstance    invalid scripting component instance
  1259.             errOSASystemError
  1260.  
  1261.         Type of a dialect info record containing at least keyOSADialectName
  1262.         and keyOSADialectCode fields.
  1263.  
  1264.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1265.  
  1266.         Field of a typeOSADialectInfo record of typeChar.
  1267.         Field of a typeOSADialectInfo record of typeShortInteger.
  1268.         Field of a typeOSADialectInfo record of typeShortInteger.
  1269.         Field of a typeOSADialectInfo record of typeShortInteger.
  1270.     */
  1271. /**************************************************************************
  1272.     OSA Optional Event Handling Interface
  1273. **************************************************************************
  1274.     Scripting components that support the Event Handling interface have the 
  1275.     kOSASupportsEventHandling bit set in their ComponentDescription.
  1276. **************************************************************************/
  1277. EXTERN_API( OSAError )
  1278. OSASetResumeDispatchProc        (ComponentInstance         scriptingComponent,
  1279.                                  AEEventHandlerUPP         resumeDispatchProc,
  1280.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0801, 0x7000, 0xA82A);
  1281.  
  1282. /*
  1283.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1284.         This function is used to set the ResumeDispatchProc that will be used
  1285.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1286.         found in the context, or the context event hander "continues" control
  1287.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1288.         may also be passed to this routine indicating that the handler registered
  1289.         in the application with AEInstallEventHandler should be used, or no
  1290.         dispatch should occur, respectively.
  1291.     
  1292.         Errors:
  1293.             badComponentInstance    invalid scripting component instance
  1294.             errOSASystemError
  1295.     */
  1296. enum {
  1297.     kOSAUseStandardDispatch        = kAEUseStandardDispatch
  1298. };
  1299.  
  1300. /*
  1301.         Special ResumeDispatchProc constant which may be passed to 
  1302.         OSASetResumeDispatchProc indicating that the handler registered
  1303.         in the application with AEInstallEventHandler should be used.
  1304.         
  1305.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1306.                 doesn't allow pointer types to be assigned to an enum.  All
  1307.                 constants must be assigned as enums to translate properly to
  1308.                 Pascal.
  1309.     */
  1310. enum {
  1311.     kOSANoDispatch                = kAENoDispatch
  1312. };
  1313.  
  1314. /*
  1315.         Special ResumeDispatchProc constant which may be passed to 
  1316.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1317.         
  1318.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1319.                 doesn't allow pointer types to be assigned to an enum.  All
  1320.                 constants must be assigned as enums to translate properly to
  1321.                 Pascal.
  1322.     */
  1323. enum {
  1324.     kOSADontUsePhac                = 0x0001
  1325. };
  1326.  
  1327. /*
  1328.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1329.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1330.         This causes the standard dispatch to be performed, except the phac
  1331.         handler is not called.  This is useful during tinkerability, when
  1332.         the phac handler is used to lookup a context associated with an event's 
  1333.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1334.         bypass the phac handler would result in an infinite loop.
  1335.     */
  1336. EXTERN_API( OSAError )
  1337. OSAGetResumeDispatchProc        (ComponentInstance         scriptingComponent,
  1338.                                  AEEventHandlerUPP *    resumeDispatchProc,
  1339.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0802, 0x7000, 0xA82A);
  1340.  
  1341. /*
  1342.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1343.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1344.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1345.     
  1346.         Errors:
  1347.             badComponentInstance    invalid scripting component instance
  1348.             errOSASystemError
  1349.     */
  1350. EXTERN_API( OSAError )
  1351. OSAExecuteEvent                    (ComponentInstance         scriptingComponent,
  1352.                                  const AppleEvent *        theAppleEvent,
  1353.                                  OSAID                     contextID,
  1354.                                  long                     modeFlags,
  1355.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0803, 0x7000, 0xA82A);
  1356.  
  1357. /*
  1358.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1359.         This call is similar to OSAExecute except the initial command to
  1360.         execute comes in the form of an AppleEvent.  If the contextID
  1361.         defines any event handlers for that event, they are used to process
  1362.         the event.  If no event handler can be found in the context
  1363.         errAEEventNotHandled is returned.  If an event handler is found and
  1364.         the hander "continues" control onward, the ResumeDispatchProc
  1365.         (registered with OSASetResumeDispatchProc, above) is called given the
  1366.         AppleEvent.  The result is returned as a scriptValueID.
  1367.     
  1368.         Errors:
  1369.             badComponentInstance    invalid scripting component instance
  1370.             errOSASystemError
  1371.             errOSAInvalidID
  1372.             errOSAScriptError:        the executing script got an error
  1373.             errAEEventNotHandled:    no handler for event in contextID
  1374.     
  1375.         ModeFlags:
  1376.             kOSAModeNeverInteract
  1377.             kOSAModeCanInteract
  1378.             kOSAModeAlwaysInteract
  1379.             kOSAModeCantSwitchLayer
  1380.             kOSAModeDontReconnect
  1381.             kOSAModeDoRecord
  1382.     */
  1383. EXTERN_API( OSAError )
  1384. OSADoEvent                        (ComponentInstance         scriptingComponent,
  1385.                                  const AppleEvent *        theAppleEvent,
  1386.                                  OSAID                     contextID,
  1387.                                  long                     modeFlags,
  1388.                                  AppleEvent *            reply)                                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0804, 0x7000, 0xA82A);
  1389.  
  1390. /*
  1391.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1392.         This call is similar to OSADoScript except the initial command to
  1393.         execute comes in the form of an AppleEvent, and the result is an 
  1394.         AppleEvent reply record.  If the contextID defines any event handlers
  1395.         for that event, they are used to process the event.  If no event handler
  1396.         can be found in the context errAEEventNotHandled is returned.  If an
  1397.         event handler is found and the hander "continues" control onward, the
  1398.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1399.         called given the AppleEvent.  The result is returned in the form of an
  1400.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1401.         if the ResumeDispatchProc returns a reply event indicating an error,
  1402.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1403.         should never return errOSAScriptError).  Any error result returned by
  1404.         the ResumeDispatchProc will be returned by OSADoEvent.
  1405.     
  1406.         Errors:
  1407.             badComponentInstance    invalid scripting component instance
  1408.             errOSASystemError
  1409.             errOSAInvalidID
  1410.             errAEEventNotHandled:    no handler for event in contextID
  1411.     
  1412.         ModeFlags:
  1413.             kOSAModeNeverInteract
  1414.             kOSAModeCanInteract
  1415.             kOSAModeAlwaysInteract
  1416.             kOSAModeCantSwitchLayer
  1417.             kOSAModeDontReconnect
  1418.             kOSAModeDoRecord
  1419.     */
  1420. EXTERN_API( OSAError )
  1421. OSAMakeContext                    (ComponentInstance         scriptingComponent,
  1422.                                  const AEDesc *            contextName,
  1423.                                  OSAID                     parentContext,
  1424.                                  OSAID *                resultingContextID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0805, 0x7000, 0xA82A);
  1425.  
  1426. /*
  1427.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1428.         Makes a new empty context which may be passed to OSAExecute or 
  1429.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1430.         created. If parentContext is kOSANullScript then the resulting context
  1431.         does not inherit bindings from any other context.
  1432.     
  1433.         Errors:
  1434.             badComponentInstance    invalid scripting component instance
  1435.             errOSASystemError
  1436.             errOSAInvalidID
  1437.             errAECoercionFail:        contextName is invalid
  1438.     */
  1439.  
  1440. #if PRAGMA_STRUCT_ALIGN
  1441.     #pragma options align=reset
  1442. #elif PRAGMA_STRUCT_PACKPUSH
  1443.     #pragma pack(pop)
  1444. #elif PRAGMA_STRUCT_PACK
  1445.     #pragma pack()
  1446. #endif
  1447.  
  1448. #ifdef PRAGMA_IMPORT_OFF
  1449. #pragma import off
  1450. #elif PRAGMA_IMPORT
  1451. #pragma import reset
  1452. #endif
  1453.  
  1454. #ifdef __cplusplus
  1455. }
  1456. #endif
  1457.  
  1458. #endif /* __OSA__ */
  1459.  
  1460.